package com.flurry.android;

import android.content.Context;
import android.os.Looper;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

final class ce
{
  private static volatile String ei = null;
  private static volatile String ej = "http://data.flurry.com/aap.do";
  private static volatile String ek = "https://data.flurry.com/aap.do";
  private static boolean el = false;
  FlurryDataSenderIndex em = null;
  private String en = null;
  private String eo = null;
  Set<String> ep = new HashSet();
  private Context mContext = null;

  ce(Context paramContext, String paramString1, String paramString2)
  {
    if (Looper.myLooper() == Looper.getMainLooper())
      cy.d("FlurryDataSender", "FlurryDataSender constructor running on the MAIN thread!");
    this.mContext = paramContext;
    this.en = paramString1;
    this.eo = paramString2;
    this.em = new FlurryDataSenderIndex(paramContext, au());
    av();
  }

  private void av()
  {
    if ((FlurryAgent.an != null) && (!FlurryAgent.an.getNetworkStatus()))
      cy.g("FlurryDataSender", "Reports were not sent! No Internet connection!");
    label81: String str2;
    byte[] arrayOfByte;
    label192: label196: 
    while (true)
    {
      return;
      String str1 = au();
      List localList = this.em.getNotSentBlocksForDataKey(str1);
      if ((localList != null) && (!localList.isEmpty()))
      {
        cy.e("FlurryDataSender", "Number of not sent blocks = " + localList.size());
        int i = 0;
        if (i < localList.size())
        {
          str2 = (String)localList.get(i);
          if (!this.ep.contains(str2))
            if (this.ep.size() > 8)
              break label192;
        }
        for (int j = 1; ; j = 0)
        {
          if (j == 0)
            break label196;
          arrayOfByte = new FlurryDataSenderBlockInfo(this.mContext, str2).getData();
          if ((arrayOfByte != null) && (arrayOfByte.length != 0))
            break label198;
          cy.d("FlurryDataSender", "Internal ERROR! Report is empty!");
          this.em.removeBlockInfoWithIdentifier(str2, str1);
          i++;
          break label81;
          break;
        }
      }
    }
    label198: this.ep.add(str2);
    String str3;
    if (ei != null)
      str3 = ei;
    while (true)
    {
      cy.e("FlurryDataSender", "FlurryDataSender: start upload data with id = " + str2 + " to " + str3);
      HashMap localHashMap = new HashMap();
      localHashMap.put("del", new cu(this));
      localHashMap.put("url", str3);
      localHashMap.put("data", arrayOfByte);
      localHashMap.put("id", str2);
      new FlurryDataSenderAsyncOperation().execute(new HashMap[] { localHashMap });
      break;
      if (el)
        str3 = ek;
      else
        str3 = ej;
    }
  }

  static boolean getUseHttps()
  {
    return el;
  }

  static void setReportUrl(String paramString)
  {
    if (paramString != null)
      paramString.endsWith(".do");
    ei = paramString;
  }

  static void setUseHttps(boolean paramBoolean)
  {
    el = paramBoolean;
  }

  public final void a(byte[] paramArrayOfByte)
    throws IOException
  {
    if ((paramArrayOfByte == null) || (paramArrayOfByte.length == 0))
    {
      cy.d("FlurryDataSender", "Report that has to be sent is EMPTY or NULL");
      return;
    }
    String str = au();
    if (str != null)
    {
      FlurryDataSenderBlockInfo localFlurryDataSenderBlockInfo = new FlurryDataSenderBlockInfo(this.mContext);
      localFlurryDataSenderBlockInfo.setData(paramArrayOfByte);
      localFlurryDataSenderBlockInfo.getIdentifier();
      this.em.addBlockInfo(localFlurryDataSenderBlockInfo, str);
    }
    av();
  }

  final String au()
  {
    return "Data_" + this.en + "_" + this.eo;
  }

  final void onNetworkStateChanged(boolean paramBoolean)
  {
    if (paramBoolean)
      av();
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.flurry.android.ce
 * JD-Core Version:    0.6.2
 */